package com.yanqu.road.server.cmd.grandchild.exam;

import com.yanqu.road.pb.grandchild.GrandChildProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = GameProtocol.S_GRAND_CHILD_SYNC_IMPERIAL_EXAM_JOIN_FROM_CROSS, desc = "增量同步考场的参赛门生")
public class SyncJoinImperialExamFromCrossCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        GrandChildProto.SyncJoinExamDataMsg reqMsg = GrandChildProto.SyncJoinExamDataMsg.parseFrom(packet.getBytes());
        GrandChildProto.SyncJoinExamDataMsg.Builder builder = reqMsg.toBuilder();
        // 同步给在线玩家
        for (GamePlayer onlinePlayer : GamePlayerMgr.getAllOnlinePlayer()) {
            onlinePlayer.sendPacket(ClientProtocol.U_GRAND_CHILD_SYNC_IMPERIAL_EXAM_JOIN, builder);
        }
    }

}
